{extend name="public:layout" /}

{block name="title"}
	<title>{:site('siteName')}-挂售记录</title>
{/block}

{block name="css"}
	<link rel="stylesheet" type="text/css" href="__STATIC__/{$theme}/css/user.css">
	<link rel="stylesheet" href="__STATIC__/share/css/share.css" type="text/css" />
{/block}

{block name="content"}
	<div class="layui-main">
		<div class="user-main">
			<div class="user-left">
				{include file="public:user" index="0" /}
			</div>
			<div class="user-right">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li>
							<a href="/sell">申请挂售</a>
						</li>
						<li class="layui-this">
							<a href="/mySell">挂售记录</a>
						</li>
					</ul>
					<div class="layui-tab-content">
						<blockquote class="layui-elem-quote layui-quote-nm">注意：超时未确认，系统将会自动确认已完成，如还未收到款，请在超时之前联系客服延长超时时间并及时和接单人沟通。</blockquote>
						<table class="table">
						    <thead>
						        <tr>
						            <th>时间</th>
						            <th>超时</th>
						            <th>接单人手机</th>
						            <th>申请</th>
						            <th>手续</th>
						            <th>应付</th>
						            <th>状态</th>
						            <th>备注</th>
						            <th>操作</th>
						        </tr>
						    </thead>
						    <tbody>
								{volist name="list" id="v"}
							        <tr>
							            <td>{:date('Y-m-d',$v['time'])}</td>
							            <td>{:date('H:i:s',$v['timeout'])}</td>
							            <td>{:get_userinfo($v['agent_id'],'mobile')}</td>
							            <td>{$v['money'] + $v['fee']}</td>
							            <td>{$v.fee}</td>
							            <td>{$v.money}</td>
							            <td>
							            	{eq name="v.status" value="0"}出售中{/eq}
							            	{eq name="v.status" value="1"}已接单{/eq}
							            	{eq name="v.status" value="2"}已支付{/eq}
							            	{eq name="v.status" value="3"}已完成{/eq}
							            	{eq name="v.status" value="4"}已撤销{/eq}
							            </td>
							            <td>{$v.note}</td>
							            <td>
							            	{eq name="v.status" value="0"}
												<button class="layui-btn layui-btn-mini layui-btn-red revoke" sell_id="{$v.id}">撤销</button>
							            	{/eq}
							            	{eq name="v.status" value="2"}
												<button class="layui-btn layui-btn-mini layui-btn-main confirm" sell_id="{$v.id}">确认</button>
							            	{/eq}
							            </td>
							        </tr>
								{/volist}
						    </tbody>
						</table>
						<div class="page">
							{$list->render()}
						</div>
					</div>
				</div> 
			</div>
		</div>
	</div>
{/block}

{block name="script"}
	<script type="text/javascript">
		layui.use(['form','layer'], function(){
			var $ = layui.jquery;
			var form = layui.form();
			var layer = layui.layer;
			//撤销
			$('.revoke').click(function() {
				var sell_id = $(this).attr('sell_id');
				checkPwd(function(pwd){
					layer.confirm('确定撤销挂售', {
			            btn: ['确定', '取消'],
			            icon: 3
			        }, function(index) {
			            layer.close(index);
			            $.post('{:url("index/sell/revoke")}', {id: sell_id,pwd:pwd}, function(res) {
			            	if(res.success == 1){
			            		layer.msg(res.msg, {
				                    time: 1000
				                }, function() {
				                    location.reload();
				                });
			            	}else{
			            		layer.msg(res.msg);
			            	}
			            });
			        });
				});
				return false;
			});
			//确认
			$('.confirm').click(function(){
				var sell_id = $(this).attr('sell_id');
				checkPwd(function(pwd){
					layer.confirm('确认已收款', {
			            btn: ['确认', '取消'],
			            icon: 3
			        }, function(index) {
			            layer.close(index);
			            $.post('{:url("index/sell/confirm")}', {id: sell_id,pwd:pwd}, function(res) {
			            	if(res.success == 1){
			            		layer.msg(res.msg, {
				                    time: 1000
				                }, function() {
				                    location.reload();
				                });
			            	}else{
			            		layer.msg(res.msg);
			            	}
			            });
			        });
				});
				return false;
			});
		});
	</script>
{/block}